#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<string.h>
#include<unistd.h>

int main()
{
  int fd = open("log1.txt",O_RDONLY);
  dup2(fd,0);
  char buffer[2048];
  size_t s = read(0,buffer,sizeof(buffer));
  if(s > 0)
  {
    buffer[s] = 0;
    printf("\n%s\n",buffer);
  }

    //int fd1 = open("log1.txt",O_WRONLY | O_CREAT | O_APPEND,0666);
    //int fd2 = open("log2.txt",O_WRONLY | O_CREAT | O_APPEND,0666);
    //int fd3 = open("log3.txt",O_WRONLY | O_CREAT | O_APPEND,0666);
    //int fd4 = open("log4txt",O_WRONLY | O_CREAT | O_APPEND,0666);//const char *a = "1234";
   
    //dup2(fd1,1);
    //printf("fd1 : %d\n",fd1);
    //printf("fd2 : %d\n",fd2);
    //printf("fd3 : %d\n",fd3);
    //printf("fd4 : %d\n",fd4);
    //fflush(stdout);
    //close(fd1);
    //close(fd2);
    //close(fd3);
    //close(fd4);
   // char buffer[1024];
  //  snprintf(buffer,sizeof(buffer),"%d",a);
  //  write(1,buffer,strlen(buffer));
  //  printf("\n");
  //  //write(1,&a,sizeof(a));
  //  return 0;
}
